﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AircraftBattleServer;

namespace StressTest
{
    class Program
    {
        static GameEngineServiceClient clt = new GameEngineServiceClient();
        static string testName = "sun";
        static string testName2 = "new";
        static int testID = 3;
        static int testID2 = 6;
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter your stress test number:");
            Console.WriteLine("Test 1: Move test");
            Console.WriteLine("Test 2: Fire test");
            string a = Console.ReadLine();

            switch (a)
            {
                case "1":
                    StressTest1();
                    break;
                case "2":
                    StressTest2();
                    break;
                default:
                    break;
            }
        }

        static void StressTest1()
        {
            // setup 
            clt.AddPlayer(testName, testID);
            clt.SetTeam(testName, 1);

            clt.AddPlayer(testName2, testID2);
            clt.SetTeam(testName2, 0);
            clt.StartGame();

            for (long i = 0; i < 1000000; i++)
            {
                clt.SetPosition(testID, i%100, (i/100)%100);
                Console.WriteLine("Move: " + i);
                Console.WriteLine("Position: " + clt.GetPosition(testID).x + " " + clt.GetPosition(testID).y);
            }
        }

        static void StressTest2()
        {
            // setup
            clt.AddPlayer(testName, testID);
            clt.StartGame();

            for (long i = 0; i < 1000000; i++)
            {
                MapData md = clt.GetMapData();
                int n = md.missiles.Length;
                clt.AddMissile(testName, 0, 0, 225);
                Console.WriteLine("Fire: " + i);
                md = clt.GetMapData();
                if (n == md.missiles.Length - 1)
                    Console.WriteLine("Missile fired successfully.");
            }
        }
    }
}
